package chat

import (
	"github.com/gin-gonic/gin"
	"goskeleton/app/model"
	"goskeleton/app/utils/response"
)

type ChatController struct {
}

func (cc *ChatController) GetChatRecords(context *gin.Context) {
	//根据传递过来的OpenId去查询对应的聊天记录
	openId := context.Query("openId")
	chatRecord := model.CreateChatFactory2(`mysql`)
	chatRecords := chatRecord.GetChatRecords(openId)
	//返回聊天记录
	response.Success(context, "查询成功", chatRecords)
}

func (cc *ChatController) GetChatMessage(context *gin.Context) {
	//根据传递过来的自身id和其它用户的id去查询对应的聊天信息并返回
	selfOpenId := context.Query("selfOpenId")
	target_user := context.Query("target_user")
	chatMessage := model.CreateChatFactory1(`mysql`)
	result := chatMessage.GetChatMessage(selfOpenId, target_user)

	response.Success(context, "查询成功", result)
}
